﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;

namespace 桌面视频录制
{
    [Serializable]
    public class DrawDottedLine : DrawLine
    {
        public DrawDottedLine(Point startPoint, Point endPoint)
            : base(startPoint, endPoint) { }
        public override void Draw(Graphics g)
        {
            Pen pen = new Pen(this.PenColor);
            pen.Width = this.PenWidth;
            pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
            pen.DashPattern = new float[] { 5.0f, 3.0f };
            if (isLeftEnabled == false && isRightEnabled == false)
                g.DrawLine(pen, startPoint, endPoint);
            else if (isLeftEnabled && !isRightEnabled)
                g.DrawCurve(pen, new Point[] { startPoint, middleLeftPoint, endPoint });
            else if (!isLeftEnabled && isRightEnabled)
                g.DrawCurve(pen, new Point[] { startPoint, middleRightPoint, endPoint });
            else if (isLeftEnabled && isRightEnabled)
                g.DrawCurve(pen, new Point[] { startPoint, middleLeftPoint, middleRightPoint, endPoint });
            pen.Dispose();
        }
        public override string ToString()
        {
            string printMsg = "[虚线(" + this.startPoint.X + "," + this.startPoint.Y + ")]->[ID:" + this.Id + "]";
            return printMsg;
        }
        public override string GetDrawObjectMsg()
        {
            int angle = (int)(Math.Atan2(endPoint.Y - startPoint.Y, endPoint.X - startPoint.X) * 180 / Math.PI);
            string drawObjectMsg = "虚线->起始位置(" + this.startPoint.X + "," + this.startPoint.Y + "),终点位置(" + this.endPoint.X + "," + this.endPoint.Y + "),水平偏角:" + angle + "°";
            return drawObjectMsg;
        }
    }
}
